-- This button uses the DeleteResFork XCMD to delete the
-- resource fork of a stack.
deleteresfork
put the result
end mouseUp
-- part 4 (field)
-- low flags: 80
-- high flags: 2007
-- rect: left=12 top=26 right=298 bottom=491
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 22
-- text size: 10
-- style flags: 0
-- line height: 13
-- part name: Source
-- part 5 (button)
-- low flags: 00
-- high flags: A003
-- rect: left=314 top=300 right=322 bottom=435
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Show LSP Source
----- HyperTalk script -----
on mouseUp
set the visible of card field 1 to not the visible of card field 1
if the visible of card field 1 is true then
set the name of me to "Hide LSP Source"
else set the name of me to "Show LSP Source"
end mouseUp
-- part contents for background part 16
----- text -----
DELETERESFORK XCMD version 1.0
July 7, 1988
Kevin Calhoun
DeleteResFork deletes the resource fork of a stack while leaving the data fork intact.
Each Macintosh file, including HyperCard stacks, has two forks--a resource fork and a data fork, either of which may be empty. HyperCard stores all the information about buttons, fields, text, and pictures in the data fork of your stacks. XCMD's, XFCN's, PICT's, and other resources are stored in the resource fork.
DeleteResFork is for that trying moment when you discover that the resource fork of a stack has been ruined. If this should occur, all of the data HyperCard relies on will still be intact--it's stored in the data fork--but you'll need to jettison your garbled resource fork and then recopy the necessary resources.
How can you tell if the resource fork has been ruined? If ResEdit tells you that there was an error while opening the stack or if a disk utility tells you that the resource fork still takes up disk space even though HyperCard can't find the resources, then you know that your resource fork has been compromised. (Sometimes HyperCard can't find newly copied resources until you close the stack and then reopen it. Don't panic until after you've tried this.)
DeleteResFork won't let you regain access to a ruined resource fork. Instead, it just gets rid of it. It lets you "shake loose" a worthless resource fork that can't be read and start afresh.
NOTE: It's unwise to delete the resource fork of a stack that is already open. Make a copy of the stack and then work on the copy.
INVOKING DELETERESFORK
DeleteResFork «fileName»
DeleteResFork takes one optional parameter, the full pathname of the file whose resource fork you want to delete. If the file name is not supplied, a standard file dialog box appears, from which you can select a stack.
If the file name supplied is not the full pathname of an extant stack, or if there is any other error, DeleteResFork will return an error message as the Result. The first word of this message will be "Error."
NOTE FOR ADVANCED PROGRAMMERS:
Because XCMD's have no "owned resources" and because there's no official "XCMD Mover," you can never count on resources such as DITL's or STR#'s being around when you need them. The PrintField XCMD checks for the presence of the proper resources for its dialog. If they're there it displays its dialog; otherwise it goes ahead and prints without the dialog. With DeleteResFork, I took a different approach--it creates a dialog without using a DITL resource for the dialog item list.
The functions AddButton, AddUserItem, and AddStatText append a new item to a dialog item list in memory. The function MakeDITL uses these to build an item list from scratch.
(Roger tells me that Tech Note #95, How To Add Items to the Print Dialogs, includes some code that handles the general case of adding an item to an item list.)
The drawback to creating a dialog item list on the fly without resources is that you can't alter the text of the dialog (other than the paramText) without recompiling the source code. However, in the case of XCMD's it may be more valuable to be certain that a vital resource isn't missing than it is to enable alteration of titles and text without source code.
Perhaps the ideal solution is to include both the resources and the code to create them on the fly. If the resources are present, go ahead. If not, create them.
DeleteResFork also contains a filter for ModalDialog that handles the usual keyboard equivalents for Cancel (command-period, command-q, command-Q, escape, tilde) and OK (return and enter).